import { createRouter, createWebHistory } from 'vue-router'

import { constantRoute } from './origin'
import Nprogress from 'nprogress'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: constantRoute,
})

router.beforeEach(async (to, from, next) => {
  Nprogress.start()
  // 写路由拦截的业务处理
  next()
})

router.afterEach(() => {
  Nprogress.done()
})

export default router
